package eli.turchinsky.software.agame.enteties;

import android.content.res.Resources;
import android.graphics.Canvas;
import eli.turchinsky.software.agame.IUpdatableAndDrawable;
import eli.turchinsky.software.agame.Sprite;
import eli.turchinsky.software.agame.hood.Vector2;

public abstract class  GameEntety implements IUpdatableAndDrawable {
	protected Sprite _sprite;
	protected float _width,_height;	
	protected Vector2 _position;
	protected Vector2 _velocity;
	protected float _gravityPower;
	protected Resources _resources;
	private boolean _isMoving;

	private Star _touchingStar=null;	
	public GameEntety(float x,float y,float  width, float height,Resources resources){
			_isMoving=false;
			_position=new Vector2(x,y);
			_velocity=new Vector2(0,0);
			_width=width;
			_height=height;
			_resources = resources;
			_sprite=new Sprite();
	}
	public float getGravityPower() {
		return _gravityPower;
	}

	public void setGravityPower(float _gravityPower) {
		this._gravityPower = _gravityPower;
	}
	public void init() {				
	}

	public void draw(Canvas canvas) {
		_sprite.draw(canvas);
	}

	public void update(long gameTime) {	
		_position.add(_velocity);
		_sprite.update(gameTime);
		_sprite.setX((int)_position.getX());
		_sprite.setY((int)_position.getY());
	}
	public Vector2 getVelocity(){
		return _velocity;
	}
	public Vector2 setCenterPos(Vector2 v){
		return _position.set(v.getX()-_width/2, v.getY()-_height/2);
	}
	public Vector2 getPosition(){
		return _position;
	}
	public Vector2 getCenterPos() {
		return new Vector2(_position.getX()+_width/2,_position.getY()+_height/2);
	}		
	public void moveLeft(){
		
	}
	public void moveRight(){
		
	}	
	public boolean isCircleColide(GameEntety e){
		return (e._width/2+_width/2)>getCenterPos().distance(e.getCenterPos());			
	}
	public Star getTouchingStar() {
		return _touchingStar;
	}
	public void setTouchingStar(Star _touchingStar) {
		this._touchingStar = _touchingStar;
	}
	public boolean isMoving() {
		return _isMoving;
	}
	public void setMoving(boolean isMoving) {
		this._isMoving = isMoving;
	}
	public float getWidth() {
		return _width;
	}
	public float getHeight() {
		return _height;
	}	
}
